package com.imot.utils;

import cn.hutool.core.util.CharsetUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;

import static com.imot.constant.LoginConstant.KEY;



public class SecureCodeUtil {
    //加密
    public static String encrypt(String content) {
        //构建
        SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, KEY);
        String s = aes.encryptHex(content);
        return s;
    }

    //解密
    public static String decrypt(String encryptHex) {
        //构建
        SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, KEY);
        String decryptStr = aes.decryptStr(encryptHex, CharsetUtil.CHARSET_UTF_8);
        return decryptStr;
    }

}
